# Maintainer: Andrea Zagli <andrea.zagli.free@gmail.com>

_realname=template-glib
_base_ver=3.19.4
pkgbase=mingw-w64-${_realname}-git
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}-git"
pkgver=3.19.4.49.f2435ac
pkgrel=1
arch=('any')
pkgdesc="A templating library for GLib (mingw-w64)"
depends=("${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-gobject-introspection")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "gtk-doc"
             "flex"
             "bison"
             "autoconf-archive")
options=('!strip' 'debug' 'staticlibs')
license=("LGPL 2.1")
url="http://www.gnome.org/"
source=(git+http://git.gnome.org/browse/${_realname}
        001-win.patch)
sha256sums=('SKIP'
            'c20511d44927c23f26641949ee4b9b4010c52d624b1818e2fe1a007e10fa850a')

pkgver() {
  cd "$srcdir/$_realname"
  printf "%s.%s.%s" "${_base_ver}" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
  cd ${_realname}

  patch -b -V simple -p1 -i ${srcdir}/001-win.patch

  aclocal --install -I build-aux || exit 1
  gtkdocize || exit 1
  autoreconf --force --install -Wno-portability || exit 1
}

build() {
  mkdir -p build-${MINGW_CHOST}
  cd build-${MINGW_CHOST}

  ../${_realname}/configure \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib \
    --enable-vala=no
  make
}

package() {
  cd "$srcdir/build-${MINGW_CHOST}"
  make DESTDIR=$pkgdir install

  install -Dm644 "${srcdir}/${_realname}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
